﻿// Copyright 2006 - Ricardo Stuven (rstuven@gmail.com)
//
// This file is part of MsSqlSpatial.
// MsSqlSpatial is free software; you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
// 
// MsSqlSpatial is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU Lesser General Public License for more details.

// You should have received a copy of the GNU Lesser General Public License
// along with MsSqlSpatial; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA 

using System.Data;
using System.Data.SqlClient;
using MsSqlSpatial;

public partial class StoredProcedures
{
    public static void ExecuteCreateMetaTables(SqlCommand command)
    {
        GeometryColumnsTable.ExecuteCreate(command);
        SpatialRefSysTable.ExecuteCreate(command);
    }

    public static void ExecuteBackupMetaTables(SqlCommand command)
    {
        GeometryColumnsTable.ExecuteBackup(command);
        SpatialRefSysTable.ExecuteBackup(command);
    }

    public static void ExecuteAddGeometryQueryFunctions(SqlCommand command, string schemaName, string tableName,
                                                        string columnName)
    {
        DatabaseHelper.BuildCommand(command, "[ST].[AddGeometryQueryFunctions]");
        command.CommandType = CommandType.StoredProcedure;
        command.Parameters.AddWithValue("@schema_name", schemaName);
        command.Parameters.AddWithValue("@table_name", tableName);
        command.Parameters.AddWithValue("@column_name", columnName);
        command.ExecuteNonQuery();
    }

    public static void ExecuteDropGeometryQueryFunctions(SqlCommand command, string schemaName, string tableName,
                                                         string columnName)
    {
        DatabaseHelper.BuildCommand(command, "[ST].[DropGeometryQueryFunctions]");
        command.CommandType = CommandType.StoredProcedure;
        command.Parameters.AddWithValue("@schema_name", schemaName);
        command.Parameters.AddWithValue("@table_name", tableName);
        command.Parameters.AddWithValue("@column_name", columnName);
        command.ExecuteNonQuery();
    }
} ;